package org.eenie.cartoonist.ui;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.TextView;

import org.eenie.cartoonist.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MultiLevelActivity extends AppCompatActivity {


    @Bind(R.id.txtLevel)
    TextView txtLevel;
    View v;

    PopupWindow ppWin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_level);
        ButterKnife.bind(this);

        v = getLayoutInflater().inflate(R.layout.book_window, null);
        ppWin = new PopupWindow(v, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);

    }

    @OnClick(R.id.txtLevel)
    public void onClick() {

        if (ppWin.isShowing()) {
            ppWin.dismiss();
        } else {
            showWin();
        }


    }


    public void showWin() {
        ppWin.setTouchable(true);
        ppWin.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                return false;
            }
        });
        ppWin.setBackgroundDrawable(getResources().getDrawable(
                R.mipmap.ic_default));
        ppWin.showAsDropDown(txtLevel);

    }



}
